
function activatePlayer( player_id , elActivating ) {
	if ( typeof elActivating !== "undefined" ) {
		//need to activate the phase in question as well
		//alert( elActivating.id );

		if ( elActivating.className.search( "yactive" ) !== -1 || document.getElementById( "participant_row-" + player_id ).className.search( "yactive" ) !== -1) {
			//shit was already active yo
			//go ahead and make them all nactive
			combatLogClearActive();
			participantsClearActive();
			} else {
			combatLogClearActive();
			participantsClearActive();
			elActivating.className = elActivating.className.replace( "nactive" , "yactive");
			document.getElementById( "participant_row-" + player_id ).className = document.getElementById( "participant_row-" + player_id ).className.replace( "nactive" , "yactive");
			}
		}
	
	}

function participantsClearActive() {
	var participants = getParticipants();
	
	for ( ii=0; ii < participants.length ; ii++ ) {
		var participant_id = "participant_row-" + ii;
		var participant_row = document.getElementById( participant_id );
		if (participant_row.className.search("yactive") !== -1 ) {
			participant_row.className = participant_row.className.replace( "yactive" , "nactive");
			}
		}
	return true;
	}
	
function getParticipants() {
	var participants = new Array();
	var participantNames = document.getElementsByName("participant_name");
	var participantSPDs = document.getElementsByName("participant_spd");
	var participantDEXs = document.getElementsByName("participant_dex");
	if ( participantNames.length > 0 ) {
		//great, found some. so process them.
		for (ii = 0; ii < participantNames.length ; ii++ ) {
			var foundParticipant = new participant( participantNames[ii].value , participantSPDs[ii].value , participantDEXs[ii].value );
			participants.push(foundParticipant);
			}
		}
	return participants;
	}

function determinePhases( argSPD ) {
	var phases;
	switch ( argSPD ) {
		case 1:
			phases = new Array( 7 );
			break;
		case 2:
			phases = new Array( 6 , 12 );
			break;
		case 3:
			//alert("Test!");
			phases = new Array( 4 , 8 , 12 );
			break;
		case 4:
			phases = new Array( 3, 6 , 9 , 12 );
			break;
		case 5:
			phases = new Array( 3 , 5 , 8 , 10 , 12 );
			break;
		case 6:
			phases = new Array( 2 , 4 , 6 , 8 , 10 , 12 );
			break;
		case 7:
			phases = new Array( 2 , 4 , 6 , 7 , 9 , 11 , 12 );
			break;
		case 8:
			phases = new Array( 2 , 3 , 5 , 6 , 8 , 9 , 11 , 12  );
			break;
		case 9:
			phases = new Array( 2 , 3 , 4 , 6 , 7 , 8 , 10 , 11 , 12 );
			break;
		case 10:
			phases = new Array( 2 , 3 , 4 , 5 , 6 , 8 , 9 , 10 , 11 , 12 );
			break;
		case 11:
			phases = new Array( 2 , 3 , 4 , 5 , 6 , 7 , 8 , 9 , 10 , 11 , 12 );
			break;
		case 12:
			phases = new Array( 1 , 2 , 3 , 4 , 5 , 6 , 7 , 8 , 9 , 10 , 11 , 12 );
			break;
		}
	return phases;
	}